package com.wangjie.prefixsum;

/**
 * @author jieshao
 * @date 2022/3/23 17:59
 *
 * 304. 二维区域和检索 - 矩阵不可变
 */
public class Test02 {
    public static void main(String[] args) {
        int[][] arr = {{5, 4, -2, 7}, {8, 10, 2, 6}, {1, 15, 30, 23}, {20, 9, -11, 51}};

        NumMatrix matrix = new NumMatrix(arr);
        int res1 = matrix.sumRegion(1, 1, 2, 2);
        int res2 = matrix.sumRegion(1, 1, 3, 3);
        int res3 = matrix.sumRegion(2, 1, 3, 3);

        System.out.println("res1 = " + res1);
        System.out.println("res2 = " + res2);
        System.out.println("res3 = " + res3);
    }
}